Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

240
Views
How to achieve "e.target.value" in react native

i wanna access button value in react native, in pure javascript it look like :

const checkingStuff = (e) => console.log(e.target.value)

<button onclick={checkingStuff} > this is the value </button>.

how to achieve the same thing in react native?

edit : please answer in react native, not react js, because

<Button
onPress={checkingStuff}
title='lalala123'/>

give me 'undefined'.

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

event handlers give you inherent access to the event through the function. Unless specifically setting state within the DOM, there's no need to do an inline arrow function. You can simply reference the function like so:

const checkingStuff = (e) => { console.log(e.target.value) }

<button onClick={checkingStuff} > Set state and add your {value} like so </button>
about 4 years ago · Juan Pablo Isaza Report

0

I don't know excatly what you try to achieve, however you should access the event directly in the input instead of the button. For TextInput in React Native, the changed text is passed as a single string argument to the callback handler.

You can try this

const [text, onChangeText] = useState("")
const onPress = () => {
   console.log(text)
}

return (
    <>
        <TextInput value={text} onChangeText={onChangeText}>
        <Button onPress={onPress}/>
    </>
)
about 4 years ago · Juan Pablo Isaza Report

0

You can get like this:

const checkingStuff = (e) => console.log(e.target.value)

<button onclick={(e) => checkingStuff(e)} > this is the value </button>
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!